package com.jeesite.modules.ocr.entity;

import javax.validation.Valid;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.List;
import com.jeesite.common.collect.ListUtils;

import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.io.FileUtils;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;

/**
 * 模板管理Entity
 * 
 * @author 姚海陆,长春叭哥
 * @version 2024-07-29
 */
@Table(name = "ocr_template", alias = "a", label = "模板管理信息", columns = {
		@Column(name = "ocr_template_id", attrName = "ocrTemplateId", label = "模板编码", isPK = true),
		@Column(name = "tempate_category_code", attrName = "ocrTempateCategory.tempateCategoryCode", label = "模板分类"),
		@Column(name = "name", attrName = "name", label = "模板名称", queryType = QueryType.LIKE),
		@Column(name = "template_tag_names", attrName = "ocrTags.tagName", label = "标签名", queryType = QueryType.LIKE),
		@Column(name = "description", attrName = "description", label = "模板介绍"),
		@Column(name = "tempate_image", attrName = "tempateImage", label = "模板图片"),
		@Column(name = "llm_prompt", attrName = "llmPrompt", label = "模型提示词"),
		@Column(name = "algorithm_config_id", attrName = "ocrAlgorithmConfig.algorithmConfigId", label = "算法配置"),
		@Column(includeEntity = DataEntity.class), }, joinTable = {
				@JoinTable(type = Type.JOIN, entity = OcrTempateCategory.class, alias = "e", on = "e.tempate_category_code=a.tempate_category_code", attrName = "ocrTempateCategory", columns = {
						@Column(name = "tempate_category_code", attrName = "tempateCategoryCode", label = "编码", isPK = true),
						@Column(name = "tempate_category_name", attrName = "tempateCategoryName", label = "名称", queryType = QueryType.LIKE, isTreeName = true), }),
				@JoinTable(type = Type.LEFT_JOIN, entity = OcrAlgorithmConfig.class, alias = "o", on = "o.algorithm_config_id=a.algorithm_config_id", attrName = "ocrAlgorithmConfig", columns = {
						@Column(name = "algorithm_config_id", attrName = "algorithmConfigId", label = "算法配置编码", isPK = true),
						@Column(name = "name", attrName = "name", label = "算法名称", queryType = QueryType.LIKE), }), }, orderBy = "a.update_date DESC")
public class OcrTemplate extends DataEntity<OcrTemplate> {

	private static final long serialVersionUID = 1L;
	private String ocrTemplateId; // 模板编码
	private OcrTempateCategory ocrTempateCategory; // 模板分类
	private String name; // 模板名称
	private OcrTags ocrTags; // 标签名
	private String description; // 模板介绍
	private String tempateImage; // 模板图片
	private String llmPrompt; // 模型提示词
	private OcrAlgorithmConfig ocrAlgorithmConfig; // 算法配置algorithmConfigId
	private List<OcrTempateConfigs> ocrTempateConfigsList = ListUtils.newArrayList();// 子表列表4

	private String tempateImageRec;

	public String getTempateImageRec() {
		tempateImageRec = FileUtils.getFileNameWithoutExtension(getTempateImage()) + "-rec."
				+ FileUtils.getFileExtension(getTempateImage()) + "?t=" + System.currentTimeMillis();
		return tempateImageRec;
	}

	public void setTempateImageRec(String tempateImageRec) {
		this.tempateImageRec = tempateImageRec;
	}

	public OcrTemplate() {
		this(null);
	}

	public OcrTemplate(String id) {
		super(id);
	}

	public String getOcrTemplateId() {
		return ocrTemplateId;
	}

	public void setOcrTemplateId(String ocrTemplateId) {
		this.ocrTemplateId = ocrTemplateId;
	}

	@NotNull(message = "模板分类不能为空")
	public OcrTempateCategory getOcrTempateCategory() {
		return ocrTempateCategory;
	}

	public void setOcrTempateCategory(OcrTempateCategory ocrTempateCategory) {
		this.ocrTempateCategory = ocrTempateCategory;
	}

	public OcrTags getOcrTags() {
		return ocrTags;
	}

	public void setOcrTags(OcrTags ocrTags) {
		this.ocrTags = ocrTags;
	}

	@NotBlank(message = "模板名称不能为空")
	@Size(min = 0, max = 200, message = "模板名称长度不能超过 200 个字符")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Size(min = 0, max = 500, message = "模板介绍长度不能超过 500 个字符")
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getTempateImage() {
		return tempateImage;
	}

	public void setTempateImage(String tempateImage) {
		this.tempateImage = tempateImage;
	}

	@Size(min = 0, max = 1000, message = "模型提示词长度不能超过 1000 个字符")
	public String getLlmPrompt() {
		return llmPrompt;
	}

	public void setLlmPrompt(String llmPrompt) {
		this.llmPrompt = llmPrompt;
	}

	@Valid
	public List<OcrTempateConfigs> getOcrTempateConfigsList() {
		return ocrTempateConfigsList;
	}

	public void setOcrTempateConfigsList(List<OcrTempateConfigs> ocrTempateConfigsList) {
		this.ocrTempateConfigsList = ocrTempateConfigsList;
	}

	public OcrAlgorithmConfig getOcrAlgorithmConfig() {
		return ocrAlgorithmConfig;
	}

	public void setOcrAlgorithmConfig(OcrAlgorithmConfig ocrAlgorithmConfig) {
		this.ocrAlgorithmConfig = ocrAlgorithmConfig;
	}

}